import java.util.Scanner;

/**
 * 十六进制转十进制
 * Created by JiaJia on 2019/6/19 0019.
 */
public class HuaWei005 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        while (scanner.hasNext()){
            String string=scanner.nextLine();
            System.out.println(Integer.parseInt(string.substring(2),16));
        }
    }
}